package ucuenca.client.cliente;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.i18n.server.Type;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.layout.VLayout;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Clientes implements EntryPoint {
	
	public void onModuleLoad() {
		/*	
		
		///////////////////////////////////////////////////////
		HLayout layout = new HLayout();  
        layout.setWidth100();  
        layout.setHeight100();  
        layout.setMembersMargin(20);  
  
        VLayout vLayout = new VLayout();  
        vLayout.setShowEdges(true);  
        vLayout.setWidth(150);  
        vLayout.setMembersMargin(5);  
        vLayout.setLayoutMargin(10); 
        Label var1= new Label("Nombre Completo");;
        vLayout.addMember(var1);  
        vLayout.addMember(var1);  
        vLayout.addMember(var1);  
        layout.addMember(vLayout);  
  
        HLayout hLayout = new HLayout();  
        hLayout.setShowEdges(true);  
        hLayout.setHeight(150);  
        hLayout.setMembersMargin(5);  
        hLayout.setLayoutMargin(10);  
        hLayout.addMember(var1);  
        hLayout.addMember(var1);  
        hLayout.addMember(var1);  
        layout.addMember(hLayout);  
  
        layout.draw();
        //////////////////////////////////////////////////*/

		HLayout capa=new HLayout();		
		
        capa.setShowEdges(true);  
        capa.setWidth("100%"); 
        capa.setHeight("100%");
               
		// Add the nameField and sendButton to the RootPanel
		// Use RootPanel.get() to get the entire body element
		RootPanel rootPanel = RootPanel.get("nameFieldContainer");
		
		TabPanel tabPanel = new TabPanel();
		rootPanel.add(tabPanel, 10, 10);
		tabPanel.setSize("582px", "294px");
		
		AbsolutePanel PanelAgregar = new AbsolutePanel();
		tabPanel.add(PanelAgregar, "Agregar", false);
		PanelAgregar.setSize("533px", "253px");
		
		Label lblIngresarDatos = new Label("Ingresar Datos ");
		PanelAgregar.add(lblIngresarDatos, 355, 10);
		
		Label lblCedulaORuc = new Label("Cedula o Ruc:");
		PanelAgregar.add(lblCedulaORuc, 30, 50);
		
		final TextBox textBox = new TextBox();
		PanelAgregar.add(textBox, 200, 50);
		textBox.setSize("217px", "6px");
		
		Label lblNombreCompleto = new Label("Nombre Completo");
		PanelAgregar.add(lblNombreCompleto, 30,70);
		
		final TextBox textBox_1 = new TextBox();
		PanelAgregar.add(textBox_1, 200, 70);
		textBox_1.setSize("217px", "6px");
		
		Label lblDireccion = new Label("Dirección:");
		PanelAgregar.add(lblDireccion, 30, 90);
		final TextBox textBox_2 = new TextBox();
		PanelAgregar.add(textBox_2, 200, 90);
		textBox_2.setSize("217px", "6px");
		
		Label lblTelefono = new Label("Telefono:");
		PanelAgregar.add(lblTelefono, 30, 110);
		final TextBox textBox_5 = new TextBox();
		PanelAgregar.add(textBox_5, 200, 110);
		textBox_5.setSize("217px", "6px");
		
		Label lblEmail = new Label("Email:");
		PanelAgregar.add(lblEmail, 30, 130);
		
		final TextBox textBox_3 = new TextBox();
		PanelAgregar.add(textBox_3, 200, 130);
		textBox_3.setSize("217px", "6px");
		
		Label lblidCategoria = new Label("Categoria");
		PanelAgregar.add(lblidCategoria, 30,150);
		
		final TextBox textBox_4 = new TextBox();
		PanelAgregar.add(textBox_4, 200, 150);
		textBox_4.setSize("217px", "6px");
		
		Button btnGuardar = new Button("Guardar");
		btnGuardar.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				String cedulaoruc=textBox.getText();
				String nombre=textBox_1.getText();
				String direccion=textBox_2.getText();
				String telefono=textBox_5.getText();
				String email=textBox_3.getText();
				String idCategoria=textBox_4.getText();
				int numcompras=0;
				cliente mi_cliente=new cliente(cedulaoruc, nombre, direccion,	telefono, email, idCategoria, numcompras);
	
				
			}
		});
		PanelAgregar.add(btnGuardar, 284, 174);
		
		Button btnCancelar = new Button("Cancelar");
		PanelAgregar.add(btnCancelar, 355, 174);		
		AbsolutePanel PanelRegistros = new AbsolutePanel();
		
		final ListGrid countryGrid = new ListGrid();  
		
		Canvas canvas = new Canvas();  
        countryGrid.setWidth(500);  
        countryGrid.setHeight("100%");  
        countryGrid.setShowAllRecords(true);  
  
        ListGridField cedula = new ListGridField("cedula", "CEDULA/RUC",50);  
        ListGridField nombre = new ListGridField("nombre", "NOMBRE",200); 
        ListGridField direccion = new ListGridField("direccion", "DIRECCION",200);
        ListGridField telefono= new ListGridField("telefono", "TELEFONO",50);
        ListGridField email = new ListGridField("email", "EMAIL",100);
        ListGridField id_categoria = new ListGridField("id_categoria", "CATEGORIA",50);
        countryGrid.setFields(new ListGridField[] {cedula, nombre, direccion, telefono, email, id_categoria});  
        //countryGrid.setData(CountryData.getRecords());  
        canvas.addChild(countryGrid);
        canvas.setAlign(Alignment.CENTER);
        PanelRegistros.add(canvas);
        
		tabPanel.add(PanelRegistros, "Registros", false);

		
		capa.setLayoutMargin(10);
		
		VLayout cap = new VLayout();
		HLayout capaux = new HLayout();
		capaux.addMember(new LayoutSpacer());
        Label titulo = new Label("MODULO CLIENTE");
        capaux.addMember(titulo);
        capaux.addMember(new LayoutSpacer());
        capaux.setHeight(50);
        cap.addMember(capaux);        
		cap.addMember(rootPanel);
		
		
		capa.addMember(new LayoutSpacer());
		capa.addMember(cap);
        capa.addMember(new LayoutSpacer());
        capa.setLayoutAlign(Alignment.CENTER);        
          
        //capa.addMember(rootPanel);
                
		capa.draw();
		
		
		//SessionFactory sesion= SessionFactoryUtil.getSessionFactory();
	}
}
